package com.digdes.calendar.dao.impl;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.digdes.calendar.model.File;
import com.digdes.calendar.model.Place;
import  com.digdes.calendar.dao.PlaceDAO;
import com.digdes.calendar.model.impl.FileImpl;
import com.digdes.calendar.model.impl.PlaceImpl;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class PlaceDAOImpl extends HibernateDaoSupport implements PlaceDAO{
    public void savePlace(Place place) {
        getHibernateTemplate().save(place);
    }

    public void updatePlace(Place place) {
        getHibernateTemplate().update(place);
    }

    public void deletePlace(Long id) {
        Object place = getHibernateTemplate().get(PlaceImpl.class, id);
        getHibernateTemplate().delete(place);
    }



    public Place findPlaceById(Long id) {
        return (Place) getHibernateTemplate().get(FileImpl.class, id);

    }


    public Set<Place> getAllPlace() {
        return new HashSet<Place>(getHibernateTemplate().loadAll(PlaceImpl.class));
    }

    public List getPlaces() {
        return getHibernateTemplate().loadAll(PlaceImpl.class);
    }


}
